Skip to content

perf: skip error list updates for unrelated notebook changes - #12256

Merged
mscolnick merged 1 commit into
mainfrom
kg/mo-8797-cache-cell-errors
Dec 3, 2026
Merged

mscolnick merged 1 commit into
mainfrom
kg/mo-8797-cache-cell-errors

Conversation

@kirangadhave

@kirangadhave kirangadhave commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

📝 Summary

Skip the full notebook scan and React commit when a log append, a code edit, or a rename leaves the displayed errors unchanged. Track actionable errors per cell and read the cell name only while it has a visible error. Keep entries in notebook order and release the per-cell atoms on deletion.

In a 500-cell notebook, 20 log appends, 20 code edits in an errored cell, and 20 renames of a healthy cell previously caused 60 full scans and 60 error-list commits. Both counts fell to zero, saving 30,000 cell ID visits. Both versions displayed the same ordered errors after every update.

Median time in jsdom 10 cells, before → after 500 cells, before → after
60 unrelated updates 2.63 → 0.62 ms 11.07 → 0.75 ms
Mount the error list 0.41 → 0.46 ms 3.41 → 4.43 ms
21 visible error additions or removals 1.95 → 2.42 ms 26.17 → 37.61 ms

At 500 cells, unrelated updates were faster in all six alternating pairs against 06fe945858. Visible error changes were slower in all six. Each still triggered one scan and one commit. Total time across all three phases improved in three of six pairs. The benchmark measured one mounted list in jsdom and excluded browser layout and paint.

Focused tests cover multiple errors in one cell, rename, reorder, clear, deletion and re-addition, and independent notebook stores.

Addresses the cell error subscription work in MO-8797.

@kirangadhave
kirangadhave marked this pull request as ready for review December 3, 2026 01:30
@kirangadhave
kirangadhave requested review from mscolnick and a balanced review from Copilot December 3, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the notebook error-list optimization.

No open issues 🎉

What changed in this PR

Optimizes the notebook error list to avoid scans and React commits when unrelated cell changes leave displayed errors unchanged.

Changes:

  • Tracks actionable errors per cell and reads names only for cells with visible errors.
  • Preserves notebook ordering and releases cached atoms when cells are deleted.
  • Adds tests for skipped updates, error filtering, ordering, renaming, and cell lifecycle behavior across stores.
File Description
frontend/​src/​core/​cells/​cells.ts Adds per-cell error tracking, shallow comparison, and cleanup.
frontend/​src/​core/​cells/​__tests__/​cell-errors.test.tsx Tests update efficiency and error-list correctness.

Review effort: Balanced

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

React Doctor found 1 new issue in 1 file · 1 warning · score 97 / 100 (Great) · 0 fixed · vs main

1 warning

src/core/cells/cells.ts

  • ⚠️ L470 Derived atom returns fresh object jotai-derived-atom-returns-fresh-object

Reviewed by React Doctor for commit fb99022. See inline comments for fixes.

});

export const cellErrorsAtom = selectAtom(
atom((get) => get(cellIdsAtom).map((id) => get(cellErrorAtom(id)))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/jotai-derived-atom-returns-fresh-object (warning)

This derived atom returns a new array each time, so jotai's Object.is check fails & re-renders every consumer on every update. Split into one atom per field, or use selectAtom(source, fn, shallow).

Fix → Split it into one derived atom per field (each compares cleanly with Object.is), or wrap with selectAtom(source, fn, shallow) from jotai/utils if you really need one object.

Docs

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 69.25% 28694 / 41434
🔵 Statements 69.2% 29252 / 42268
🔵 Functions 64.6% 6904 / 10686
🔵 Branches 64.66% 16813 / 26002
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/core/cells/cells.ts 85.77% 86.66% 79.06% 88.48% 273-280, 309-330, 432, 441-445, 448, 515, 522, 542, 547, 559, 566, 571, 574, 633-635, 676, 692-697, 715-719
Generated in workflow #26515 for commit fb99022 by the Vitest Coverage Report Action

@mscolnick
mscolnick merged commit 7a80933 into main Dec 3, 2026
30 checks passed
@mscolnick
mscolnick deleted the kg/mo-8797-cache-cell-errors branch December 3, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants